package tsing.kc_work.cology.vipplatereceive;

import com.alibaba.fastjson.JSONObject;
import tsing.kc_work.cology.vipplatereceive.domain.ChannelCollectReqParam;
import tsing.kc_work.cology.vipplatereceive.util.DesUtil;


/**
 * @Date 2023/11/8 15:45
 *
 * 新平台权益领取工具类
 */
public class VipplateReceiveInterfaceUtil {


    public static void main(String[] args) {


        // 解密流程
//        String param = "{\"body\":\"BA9E4C91B4CEC0D4F76CA40193BCD3909823179161E7CD8C25ECE1D2D1E4B74C69E45D85A088B5A5275A14A3A7751FCC0EF8208F31C120198848C0EDB82B967B59A432B52203D2990495D042EE71F9770623D207B91B5ED6A3172A1A41668DE752FE556385A472E0AA6658A73A3C637AC5188020775DE418EC1F9ECDC34E5B2884EF598E978644586C0904C080C07D5EFC38D205F1AE819F606F5175D62BC45DC23CE5927BBC61C31BC479E076228C454DB19F111D1A33F649B6B7C794C4DD54471EC1B875D8C45B9823179161E7CD8C2E364BA89ED2D713\",\"channelId\":\"40e7dca50f5b4dd4aca7ec6ef82b611d\",\"channelName\":\"订单中心\",\"sign\":\"deb95cfbea74cd9facbd023af20a1a59\",\"timestamp\":\"1700571918735\"}" ;
        String param = "{\"body\":\"BA9E4C91B4CEC0D4835C7E37249A7E045E2B94150B7B638C25ECE1D2D1E4B74C69E45D85A088B5A5275A14A3A7751FCC0EF8208F31C120198848C0EDB82B967BE795EA9023E292B80495D042EE71F9770623D207B91B5ED6A3172A1A41668DE78BE59BA7C2A50FA8C720126C88E0B2FCEFCEC5F1F1AE9BA610D7050DC9514EC484EF598E97864458153381420D3ED2DB6CA8437D7C8DF0FD479242A232D4AF0EC23CE5927BBC61C38097653BC345E504B469D238AF31732349B6B7C794C4DD5489689086A18D98825E2B94150B7B638C2E364BA89ED2D713\",\"channelId\":\"2c7b50e1585148cf9a58522ad54ba85a\",\"channelName\":\"订单中心\",\"sign\":\"63ff7639a0d32fd1abd63225286808de\",\"timestamp\":\"1719308425169\"}";
        ChannelCollectReqParam reqParam = JSONObject.parseObject(param, ChannelCollectReqParam.class);
        // 渠道表中配置的秘钥字段
        reqParam.setSecrete("bd251fc33c5f9a27801310ff0415448e76b00d52");
        decryt(reqParam);


        System.out.println(JSONObject.toJSONString(reqParam));


    }

    /**
     * 解密
     */
    public static  boolean decryt(ChannelCollectReqParam param)  {
        boolean flag = true;
        try {
            String decode = DesUtil.decode(param.getBody(), param.getSecrete());
            param.setReqParam(decode);
        } catch (Exception e) {
            e.printStackTrace();
            flag = false;
        }
        return flag;
    }
}
